<?php

class Struktur_model extends CI_Model {

	function find_type($id)
	{
		//ELEMENT
		$query = $this->db->query
		('
    		SELECT type
		 	FROM element
			WHERE id='.$id.'
		');
		$row = $query->row();
		
		if($row->type == "begivenhed" || $row->type == "sted")
		{
			return $row->type;
		}

		if($row->type == "entitet")
		{
			$query2 = $this->db->query
			('
	    			SELECT type_kvant
			 	FROM entitet
				WHERE id='.$id.'
			');
			$row = $query2->row();

			if($row->type_kvant == "individ"){

				$query3 = $this->db->query
				('
					SELECT id
				 	FROM player_character
					WHERE id='.$id.'
				');
				if($query3->num_rows() > 0){
					return "player_character";
				}
			}

			return $row->type_kvant;
		}
	}

	function find_classes($id)
	{
		$type = $this->struktur_model->find_type($id);

		if($type == "begivenhed"){ return array('element','begivenhed'); }
		if($type == "entitet"){ return array('element','entitet'); }
		if($type == "gruppe"){ return array('element','entitet', 'gruppe'); }
		if($type == "individ"){ return array('element','entitet', 'individ'); }
		if($type == "rpg_element"){ return array('element', 'begivenhed', 'rpg_element'); }
		if($type == "sted"){ return array('element', 'sted'); }
		if($type == "player_character"){ return array('element', 'entitet', 'individ', 'player_character'); }
	}

}





?>
